/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.company.lineup;

import com.company.primitivies.Point2d;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author admin
 */
public class LineUp {

    public static double measure(List<Point2d> points) {
        double result = 0;
        Iterator<Point2d> iterator = points.listIterator();
        Point2d a = new Point2d();
        Point2d b = new Point2d();
        if (iterator.hasNext()) {
            a = iterator.next();
        }
        while (iterator.hasNext()) {

            b = iterator.next();

            result = result + Math.sqrt((a.getX() - b.getX()) * (a.getX() - b.getX()) + (a.getY() - b.getY()) * (a.getY() - b.getY()));
            a=b.clone();
        }
        return result;
    }

}
